unit NumbersContracts;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel, dxSkinCoffee,
  dxSkinDarkRoom, dxSkinDarkSide, dxSkinFoggy, dxSkinGlassOceans,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSharp, dxSkinSilver, dxSkinSpringTime,
  dxSkinStardust, dxSkinSummer2008, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinXmas2008Blue, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, ADODB,
  dxLayoutContainer, dxLayoutControl, ImgList, cxPropertiesStore,
  dxSkinsdxStatusBarPainter, dxRibbonSkins, dxSkinsdxBarPainter, dxBar,
  dxRibbon, dxStatusBar, dxSkinsdxNavBarPainter, cxTL, cxTextEdit,
  cxTLdxBarBuiltInMenu, dxSkinsdxDockControlPainter, cxPC, dxDockControl,
  dxDockPanel, cxInplaceContainer, dxNavBarCollns, dxNavBarBase, dxNavBar,
  ToolWin, ActnMan, ActnCtrls, cxSplitter, ExtCtrls, Buttons, StdCtrls,
  cxContainer, Menus, cxButtons, cxSpinEdit, cxSpinButton, cxMaskEdit,
  cxButtonEdit;

type CreateOptions = record
  FormCaption: string;
end;

type
  TNumbersContractsForm = class(TForm)
    Query: TADOQuery;
    DataSource: TDataSource;
    Panel1: TPanel;
    Panel2: TPanel;
    Panel5: TPanel;
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    btnIncreaseFont: TcxButton;
    btnDecreaseFont: TcxButton;
    btnColumnAutoWidth: TcxButton;
    btnWordWrap: TcxButton;
    btnRightColumnToggle: TcxButton;
    btnAddRecord: TcxButton;
    btnLeftColumnToggle: TcxButton;
    PropertiesStore: TcxPropertiesStore;
    ContractName: TcxGridDBColumn;
    CodeNumber: TcxGridDBColumn;
    Number: TcxGridDBColumn;
    CodeNumber1C: TcxGridDBColumn;
    procedure btnColumnAutoWidthClick(Sender: TObject);
    procedure btnDecreaseFontClick(Sender: TObject);
    procedure btnIncreaseFontClick(Sender: TObject);
    procedure btnWordWrapClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
  	procedure ChangeFontSize(S:TcxGridTableViewStyles;SizeDifference:integer=0);
    { Private declarations }

  public
    { Public declarations }
  end;

var
  NumbersContractsForm: TNumbersContractsForm;
  function ShowNumbersContracts(Options: CreateOptions): Integer;

implementation

uses Main;

{$R *.dfm}

function ShowNumbersContracts(Options: CreateOptions): Integer;
begin
  Result := -1;
  try
    Application.CreateForm(TNumbersContractsForm, NumbersContractsForm);
    NumbersContractsForm.Caption := Options.FormCaption;
    NumbersContractsForm.Show;
    Result := 1;
  except
    NumbersContractsForm.Free;
    NumbersContractsForm := nil;
  end;
end;

procedure TNumbersContractsForm.ChangeFontSize(S:TcxGridTableViewStyles ; SizeDifference:integer=0);
var i:integer;
begin
      for i:=0 to S.Count-1 do
      begin
        S.Values[i].Font.size:=S.Values[i].font.size+SizeDifference;
      end;
end;


procedure TNumbersContractsForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  PropertiesStore.StoreTo(true);
end;

procedure TNumbersContractsForm.btnColumnAutoWidthClick(Sender: TObject);
begin
  cxGrid1DBTableView1.optionsView.ColumnAutoWidth:=not(cxGrid1DBTableView1.optionsView.ColumnAutoWidth);
end;

procedure TNumbersContractsForm.btnDecreaseFontClick(Sender: TObject);
var i:integer;
begin
   cxGrid1DBTableView1.BeginUpdate;

   with cxGrid1DBTableView1.Styles do
    begin
     if (content<>nil) then Content.Font.Size:=Content.Font.Size-1;
     if (background<>nil) then background.Font.Size:=background.Font.Size-1;
     if (ContentEven<>nil) then ContentEven.Font.Size:=ContentEven.Font.Size-1;
     if (ContentOdd<>nil) then ContentOdd.Font.Size:=ContentOdd.Font.Size-1;
     if (FilterBox<>nil) then FilterBox.Font.Size:=FilterBox.Font.Size-1;
     if (FilterRowInfotext<>nil) then FilterRowInfotext.Font.Size:=FilterRowInfotext.Font.Size-1;
     if (footer<>nil) then footer.Font.Size:=footer.Font.Size-1;
     if (group<>nil) then group.Font.Size:=group.Font.Size-1;
     if (GroupByBox<>nil) then GroupByBox.Font.Size:=GroupByBox.Font.Size-1;
     if (GroupFooterSortedSummary<>nil) then GroupFooterSortedSummary.Font.Size:=GroupFooterSortedSummary.Font.Size-1;
     if (GroupSortedSummary<>nil) then GroupSortedSummary.Font.Size:=GroupSortedSummary.Font.Size-1;
     if (GroupSummary<>nil) then GroupSummary.Font.Size:=GroupSummary.Font.Size-1;
     if (Header<>nil) then Header.Font.Size:=Header.Font.Size-1;
     if (Inactive<>nil) then Inactive.Font.Size:=Inactive.Font.Size-1;
     if (incSearch<>nil) then incSearch.Font.Size:=incSearch.Font.Size-1;
     if (Indicator<>nil) then Indicator.Font.Size:=Indicator.Font.Size-1;
     if (Navigator<>nil) then Navigator.Font.Size:=Navigator.Font.Size-1;
     if (NewItemRowInfoText<>nil) then NewItemRowInfoText.Font.Size:=NewItemRowInfoText.Font.Size-1;
     if (Preview<>nil) then Preview.Font.Size:=Preview.Font.Size-1;
     if (Selection<>nil) then Selection.Font.Size:=Selection.Font.Size-1;
   
    end;

   cxGrid1DBTableView1.EndUpdate;
end;

procedure TNumbersContractsForm.btnIncreaseFontClick(Sender: TObject);
begin
   cxGrid1DBTableView1.BeginUpdate;
with cxGrid1DBTableView1.Styles do
    begin
   with cxGrid1DBTableView1.Styles do
    begin
     if (content<>nil) then Content.Font.Size:=Content.Font.Size+1;
     if (background<>nil) then background.Font.Size:=background.Font.Size+1;
     if (ContentEven<>nil) then ContentEven.Font.Size:=ContentEven.Font.Size+1;
     if (ContentOdd<>nil) then ContentOdd.Font.Size:=ContentOdd.Font.Size+1;
     if (FilterBox<>nil) then FilterBox.Font.Size:=FilterBox.Font.Size+1;
     if (FilterRowInfotext<>nil) then FilterRowInfotext.Font.Size:=FilterRowInfotext.Font.Size+1;
     if (footer<>nil) then footer.Font.Size:=footer.Font.Size+1;
     if (group<>nil) then group.Font.Size:=group.Font.Size+1;
     if (GroupByBox<>nil) then GroupByBox.Font.Size:=GroupByBox.Font.Size+1;
     if (GroupFooterSortedSummary<>nil) then GroupFooterSortedSummary.Font.Size:=GroupFooterSortedSummary.Font.Size+1;
     if (GroupSortedSummary<>nil) then GroupSortedSummary.Font.Size:=GroupSortedSummary.Font.Size+1;
     if (GroupSummary<>nil) then GroupSummary.Font.Size:=GroupSummary.Font.Size+1;
     if (Header<>nil) then Header.Font.Size:=Header.Font.Size+1;
     if (Inactive<>nil) then Inactive.Font.Size:=Inactive.Font.Size+1;
     if (incSearch<>nil) then incSearch.Font.Size:=incSearch.Font.Size+1;
     if (Indicator<>nil) then Indicator.Font.Size:=Indicator.Font.Size+1;
     if (Navigator<>nil) then Navigator.Font.Size:=Navigator.Font.Size+1;
     if (NewItemRowInfoText<>nil) then NewItemRowInfoText.Font.Size:=NewItemRowInfoText.Font.Size+1;
     if (Preview<>nil) then Preview.Font.Size:=Preview.Font.Size+1;
     if (Selection<>nil) then Selection.Font.Size:=Selection.Font.Size+1;
   
    end;
   
    end;
   cxGrid1DBTableView1.EndUpdate;
end;

procedure TNumbersContractsForm.btnWordWrapClick(Sender: TObject);
begin
  cxGrid1DBTableView1.optionsView.CellAutoHeight := not(cxGrid1DBTableView1.optionsView.CellAutoHeight);
end;

end.
